package klochkov.snake.model;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * Represent one game field's cell, can contain one entity cell. 
 * @author Dmitry_Klochkov
 *
 */
public class FieldCell {
	private EntityCell entityCell;
	private final Lock lock = new ReentrantLock();

	public EntityCell getEntityCell() {
		return entityCell;
	}

	public void setEntityCell(EntityCell entityCell) {
		this.entityCell = entityCell;
	}
	
	public boolean isEmpty(){
		return entityCell==null;
	}
	public void clear(){
		entityCell=null;
	}
	public boolean tryLock(){
		return lock.tryLock();
	}
	public void unlock(){
		lock.unlock();
	}
}
